//
//  RCUserVCScoreCell.m
//  RocketProject
//
//  Created by chen jiedan on 13-8-25.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "RCUserVCScoreCell.h"
#import "UIColor-Expanded.h"
#import "CommonDefines.h"

@implementation RCUserVCScoreHeaderCell{
    UILabel *_scoreLabel;
    UILabel *_changeLabel;

}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void) createPlaceHolder
{
    {
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(25, 25, 105, 20)];
    [self.contentView addSubview:label];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont fontWithName:kFontNameHelvetica size:15];
    label.textColor = kNormalHeadTextColor;
    label.text = @"现有积分：";
    [label sizeToFit];

    [label release];
    
    
    _scoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width, 25, 105, 15)];
    [self.contentView addSubview:_scoreLabel];
    _scoreLabel.backgroundColor = [UIColor clearColor];
    _scoreLabel.font = [UIFont fontWithName:kFontNameHelvetica size:15];
    _scoreLabel.textColor = [UIColor colorWithRed:255.0/255.0 green:121.0/255 blue:43.0/255 alpha:1];
    [_scoreLabel release];
    }
    
    
    {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(25, 50, 160, 15)];
        [self.contentView addSubview:label];
        label.backgroundColor = [UIColor clearColor];
        label.font = [UIFont fontWithName:kFontNameHelvetica size:15];
        label.textColor = kNormalHeadTextColor;
        label.text = @"最近一次积分变动：";
        [label sizeToFit];
        [label release];
        
        
        _changeLabel = [[UILabel alloc] initWithFrame:CGRectMake(label.frame.origin.x + label.frame.size.width, 50, 105, 15)];
        [self.contentView addSubview:_changeLabel];
        _changeLabel.backgroundColor = [UIColor clearColor];
        _changeLabel.textColor = [UIColor colorWithRed:255.0/255.0 green:121.0/255 blue:43.0/255 alpha:1];
        _changeLabel.font = [UIFont fontWithName:kFontNameHelvetica size:15];
        [_changeLabel release];
    }
    
    
    
    
    
}
- (void) bindData:(RCMyScoreListDataModel *)model
{
    _scoreLabel.text = model.myScore;
    if ([model.listItems count] > 0) {
        RCMyScoreItemDataModel *firstItem = [model.listItems objectAtIndex:0];
        _changeLabel.text = [NSString stringWithFormat:@"%@%@",firstItem.event,firstItem.score];
    }
  
}

@end



@implementation RCUserVCScoreItemCell{
    UILabel *_timeBtn;
    UILabel *_scoreBtn;
    UILabel *_eventBtn;
}

@synthesize isFirst = _isFirst;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createPlaceHolder];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void) createPlaceHolder
{
    
    for (int i = 0; i < 4; i++) {
        UIView *verticleLine1 = [[UIView alloc]initWithFrame:CGRectMake(10+i*100, 0, 1, 50)];
        verticleLine1.backgroundColor = [UIColor colorWithHex:0xffeaeaea];
        [self.contentView addSubview:verticleLine1];
        [verticleLine1 release];
        
        if (i < 2) {
            UIView *horizonLine = [[UIView alloc]initWithFrame:CGRectMake(10, i*49, 320-20, 1)];
            horizonLine.tag = 200 + i;
            horizonLine.backgroundColor = [UIColor colorWithHex:0xffe6e6e6];
            [self.contentView addSubview:horizonLine];
            [horizonLine release];
        }
    }
    
    _timeBtn = [[UILabel alloc] initWithFrame:CGRectMake(10+1, 1, 99, 48)];
    _timeBtn.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_timeBtn];
    _timeBtn.textAlignment = NSTextAlignmentCenter;

    [_timeBtn release];
    
    
    _scoreBtn = [[UILabel alloc] initWithFrame:CGRectMake(10+100+1, 1, 99, 48)];
    _scoreBtn.backgroundColor = [UIColor clearColor];
    _scoreBtn.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_scoreBtn];
    [_scoreBtn release];
    
    _eventBtn = [[UILabel alloc] initWithFrame:CGRectMake(10+200+1, 1, 99, 48)];
    _eventBtn.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:_eventBtn];
    _eventBtn.textAlignment = NSTextAlignmentCenter;
    [_eventBtn release];
    
    
}

- (void) bindData:(RCMyScoreItemDataModel *)item
{
    if (self.isFirst) {
        [self.contentView viewWithTag:200].hidden = NO;
        _eventBtn.textColor = [UIColor colorWithRed:255.0/255.0 green:121.0/255 blue:43.0/255 alpha:1];
        _timeBtn.textColor = [UIColor colorWithRed:255.0/255.0 green:121.0/255 blue:43.0/255 alpha:1];
        _scoreBtn.textColor = [UIColor colorWithRed:255.0/255.0 green:121.0/255 blue:43.0/255 alpha:1];
        _eventBtn.backgroundColor = [UIColor whiteColor];
        _timeBtn.backgroundColor = [UIColor whiteColor];
        _scoreBtn.backgroundColor = [UIColor whiteColor];

        _timeBtn.font = [UIFont fontWithName:kFontNameHelvetica size:15];
        _eventBtn.font = [UIFont fontWithName:kFontNameHelvetica size:15];
        _scoreBtn.font = [UIFont fontWithName:kFontNameHelvetica size:15];
        
        _eventBtn.text = @"事件";
        _timeBtn.text = @"时间";
        _scoreBtn.text = @"积分";

    }else{
        [self.contentView viewWithTag:200].hidden = YES;
        _timeBtn.font = [UIFont fontWithName:kFontNameHelvetica size:12];
        _eventBtn.font = [UIFont fontWithName:kFontNameHelvetica size:12];
        _scoreBtn.font = [UIFont fontWithName:kFontNameHelvetica size:12];

        _eventBtn.textColor = kNormalTextColor;
        _timeBtn.textColor = kNormalTextColor;
        _scoreBtn.textColor = kNormalTextColor;
        _eventBtn.backgroundColor = [UIColor clearColor];
        _timeBtn.backgroundColor = [UIColor clearColor];
        _scoreBtn.backgroundColor = [UIColor clearColor];
        _eventBtn.text = item.event;
        _timeBtn.text = item.dateTime;
        _scoreBtn.text = item.score;
    }
}

@end